package com.designpatterns.memento.originator;

import com.designpatterns.memento.memento.Memento;

/**
 * Originator Class
 * 
 * @author Haiqi.Wang
 * @since 2013-6-9下午5:09:40
 */
public class Originator {
	private String state;

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	/**
	 * create Memento Object
	 * @return {@link Memento}
	 */
	public Memento createMemento() {
		return new Memento(state);
	}

	/**
	 * set <code>Memento</code> Object
	 * @param memento {@link Memento}
	 */
	public void setMemento(Memento memento) {
		state = memento.getState();
	}

	/**
	 * show state method
	 */
	public void showState() {
		System.out.println(state);
	}
}
